﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HFK.DxFluentUI.LanguageModel;
using HFK.DxFluentUI.LanguageModel.HorizontalGrid;
using HFK.DxFluentUI.LanguageModel.Editors;

namespace HFK.DxFluentUI.HorizontalGrid.Columns
{
  public class PropertyColumnEditableValuesContext<ComponentType> : EditableValuesElement<ContinuationAndElement<HorizontalGridColumnElement<ComponentType>>>
  {
    public PropertyColumnEditableValuesContext(PropertyColumnContext<ComponentType> parent)
    {
      m_parent = parent;
    }

    #region EditableValuesElement<NextStep> Members

    public ContinuationAndElement<HorizontalGridColumnElement<ComponentType>> Values<T>(T[] valuesToUse)
    {
      DevExpress.XtraEditors.Repository.RepositoryItemComboBox comboBox = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox();
      comboBox.AutoHeight = false;
      comboBox.Items.AddRange(valuesToUse.Cast<object>().ToArray());

      m_parent.ImplementingControl.ColumnEdit = comboBox;
      m_parent.GridControl.RepositoryItems.Add(comboBox);

      return new ContinuationAndContext<HorizontalGridColumnElement<ComponentType>>(m_parent);
    }

    public EditableEditorElement<PropertyType, ContinuationAndElement<HorizontalGridColumnElement<ComponentType>>> Objects<PropertyType>(PropertyType[] valuesToUse)
    {
      return new PropertyColumnEditorContext<ComponentType, PropertyType>(m_parent, valuesToUse);
    }

    #endregion

    private PropertyColumnContext<ComponentType> m_parent;
  }
}
